package com.itheima.service.impl;

import com.itheima.mapper.EmpMapper;
import com.itheima.pojo.Report;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author hu
 * @date 2025/3/4
 */
@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private EmpMapper empMapper;

    @Override
    public Report getEmpJobData() {
        //获取数据
        List<Map<String, Object>> maps = empMapper.countJobData();
        //处理数据
        List<Object> jobList = maps.stream().map(jobData -> jobData.get("jobs")).collect(Collectors.toList());
        List<Object> dataList = maps.stream().map(jobData -> jobData.get("countJobs")).collect(Collectors.toList());
        return new Report(jobList, dataList);
    }

    @Override
    public List<Map<String, Object>> getGenderData() {
        List<Map<String, Object>> maps = empMapper.countGenderData();

        return maps;
    }
}
